/**
 * @author SilverBiology, LLC
 * @website http://code.google.com/p/gbif-spreadsheet-processor/
*/
Ext.namespace('GBIF');
Ext.namespace('GBIF.GeoSpatial')

GBIF.GeoSpatial.Georss = function(config){
	
	Ext.apply(this,config,{
			height: 400
		,	border: false
		,	zoom: 2
		,	tbar: [{
					xtype:'label'
				,	style:"padding:0px 5px"	
				,	text:'Enter GeoRSS feed:'	
			}, {
					xtype: 'textfield'  
				,	width: 350
				,	ref: '../url'
				,	name: 'urlLoad'
			}, {
					text: 'Load'
				,	style:"padding:0px 5px"
				, scope: this
				,	handler: this.loadGeoRSS
			}]
		,	proxyUrl: Config.General.Home.url + "api/getcapabilities-proxy.php?url="
	});                     
		
	GBIF.GeoSpatial.Georss.superclass.constructor.call(this, config);
}

Ext.extend(GBIF.GeoSpatial.Georss,GBIF.GeoSpatial.MapComponent, {
	
	loadGeoRSS: function(){
		combo = this.ownerCt.getComponent('combo');
		if (combo.getComponent('layerType').getRawValue() == 'GeoRss') {
			var urlValue = this.proxyUrl+this.url.getValue();
			var layerGeoRSS = new OpenLayers.Layer.GeoRSS("Fire", urlValue);
			
			if(urlValue==''){
				GBIF.GeoSpatial.Notice.msg("Error","Please enter GeoRSS URL");
			}	else {
				this.map.addLayer(layerGeoRSS);
			}
		}
					
		if(combo.getComponent('layerType').getRawValue() == 'KML'){
			var urlValue = this.proxyUrl+this.url.getValue();
			var layerKML = new OpenLayers.Layer.GeoRSS("Fire",urlValue);
			
			if(urlValue==''){
				GBIF.GeoSpatial.Notice.msg("Error","Please enter URL");
			}	else {
				this.map.addLayer(layerKML);
			}
		}
	}
});